/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package group6renderer.renderernode;

import group6renderer.Display;

/**
 *
 * @author jonnie
 */
public class TableRowNode extends BranchNode
{
    public TableRowNode(String name)
    {
	this.name=name;
    }
    
    
    @Override
    
	public void addChild(TreeNode child)throws Exception
    {
	
	if (child instanceof TableCellNode)	
		super.addChild(child);
	else
		{if (child instanceof TextNode)	
			{	parent.addChild(child);	
				TextNode tChild=(TextNode)child;
				if (tChild.checkForLetters(tChild.getText()))
					throw new Exception("Only table data 'td' are allowed inside a Table row 'tr'.Action taken: The text is printed after the table.");
			}
		else	
			throw new Exception("Only table data 'td' are allowed inside a Table row 'tr' and no other tags.");

		}
	
	}
    
    
    
    
    public void drawNode(Display disp)
    {
	
	if(goingDown)
	{
	    disp.openTableRow();
	}
	goingDown = !goingDown;
    }


    @Override
    public boolean hasClosing()
    {
	return true;
    }

    @Override
    public TreeNode copy()
    {
	return new TableRowNode(name);
    }

    
    
}
